package kr.hkit.powerjava.chapter06.work;

import java.util.Scanner;

public class Lab {
	public static void main(String[] args) {
		double divisor, divident, sum;
		int loop_count;
		
		Scanner input = new Scanner(System.in);
		divisor = 1.0;
		divident = 4.0;
		sum = 0.0;
		System.out.print("반복 횟수: ");
		loop_count = input.nextInt();
		
		while(loop_count > 0)
		{
			sum = sum + divident / divisor;
			divident = -1.0 * divident;
			divisor = divisor +2;
			loop_count--;
		}
		System.out.println("Pi = "+sum);
		System.out.println("계속 하려면 아무키나 누르십시오...");
	}

}
